home *** CD-ROM | disk | FTP | other *** search
-
- #include "InvoiceGlobals.h"
- #include "BTreeDef.h"
- #include "BTreeProtos.h"
- #include "SampleHeader.h"
- #include "Actions.h"
- // macros useful to this file only
-
- #define kICustNo 7
- #define kIInvNo 8
- #define kICustName 20
- #define kIPartNum1 6
- #define kIPartQuant1 4
- #define kIPartName1 18
- #define kIPartNum2 5
- #define kIPartQuant2 3
- #define kIPartName2 19
- #define kIPopUp 12
- #define kLoadRelated 2
- #define kIDoIt 1
- #define kIPartPrice1 23
- #define kIPartPrice2 24
- #define kITotal 25
-
- #define kIFind 1
- #define kINext 2
- #define kIPrev 3
- #define kIInsert 4
- #define kFindByCust 5
-
- //used for a lot of the dialog work
- static short JitemNo;
- static short JitemType;
- static Handle Jitem;
- static Rect JBox;
-
- // variables used for this file.
- // technically, they are global, but we don't export them elsewhere
- // because they are not used in any other file
- short actionErr;
- FileAddr CustAddr;
- FileAddr LineItemAddr1;
- FileAddr LineItemAddr2;
- FileAddr IPartAddr1;
- FileAddr IPartAddr2;
- FileAddr InvoiceAddr;
- short findingBy = kFindByNumber;
- long currentInvAddr;
- Str255 currentInvCustName;
- long currentInvNumber;
- long currentInvCustNumber;
-
- //extra Customer Record, "current record" with respect to these actions
- CustomerType iCustomer;
- //used for temporary calls when loading/updating the Invoice
- PartType gPartExtra1;
- PartType gPartExtra2;
-
- //prototypes
-
- short CheckCustomer(FileAddr *CustAddr);
- short CheckPart(FileAddr *Part1, FileAddr *Part2);
- void HandleInvoiceAction(EventRecord *theEvent,short *theItem);
- void InactivateEdit(DialogPtr theDialog, short theItem);
- void ReactivateEdit(DialogPtr theDialog, short theItem);
- void HandleIPopUp (short theItem);
- void SetAString(DialogPtr theDialog,short itemNo, Str255 theString);
- void SetANumber(DialogPtr theDialog, short itemNo, long theNumber);
- void GetAString(DialogPtr theDialog, short itemNo, Str255 theString);
- void GetANumber(DialogPtr theDialog, short itemNo, long *theNumber);
- short LoadRelated(void);
- short HandleDoIt(void);
- short LoadAndFixScreen(FileAddr InvAddr);
-
-
- // is there a valid entry in the index tree for this customer number
- short CheckCustomer(FileAddr *CustAddr){
- Str255 tempString;
- long tempLong;
- long resultLong;
- short CheckErr = 0;
- short tempShort;
- GetDialogItem(gInvoiceDialog,kICustNo,&JitemType,&Jitem,&JBox);
- GetDialogItemText(Jitem,tempString);
- StringToNum(tempString,&tempLong);
- CheckErr = Find_Equal(kCustomerNumTree, gInvoiceFCH,(Ptr)&tempLong, (Ptr)&resultLong, CustAddr, kLongCompare);
- if (CheckErr != noErr) {
- HandleErrorMsg(CheckErr);
- return CheckErr;
- }
- if (tempLong != resultLong) {
- ParamText(tempString, "\pCustomer", "\p", "\p");
- tempShort = Alert(132, NULL);
- return -1;
- }
- else
- return CheckErr;
- }//function
-
- // is there a valid entry in the index tree for this part number
- short CheckPart(FileAddr *Part1, FileAddr *Part2){
- Str255 tempString;
- long tempLong;
- long resultLong;
- long foundAddr;
- short CheckErr = 0;
- short tempShort;
- short extraErr;
- short i;
- for (i=1; i<3; i++) {
- if (i == 1) {
- JitemNo = kIPartNum1;
- }
- else if (i==2){
- JitemNo = kIPartNum2;
- }
- GetDialogItem(gInvoiceDialog,JitemNo,&JitemType,&Jitem,&JBox);
- GetDialogItemText(Jitem,tempString);
- StringToNum(tempString,&tempLong);
- CheckErr = Find_Equal(kPartNumTree, gInvoiceFCH,(Ptr)&tempLong, (Ptr)&resultLong, &foundAddr, kLongCompare);
- if (i==1) {
- *Part1 = foundAddr;
- }
- else if (i==2){
- *Part2 = foundAddr;
- }
- if (CheckErr != noErr) {
- HandleErrorMsg(CheckErr);
- continue;
- }
- if (tempLong != resultLong) {
- ParamText(tempString, "\pPart", "\p", "\p");
- tempShort = Alert(132, NULL);
- if (i==1) {
- *Part1 = -1;
- }
- else if (i==2){
- *Part2 = -1;
- }
- continue;
- }
- }//for
- return CheckErr;
- }//function
-
-
- // turns an editable text into a static text field
- void InactivateEdit(DialogPtr theDialog, short theItem){
- short itemType;
- Handle item;
- Rect box;
- GetDialogItem(theDialog, theItem, &itemType, &item, &box);
- itemType = statText;
- SetDialogItem(theDialog, theItem, itemType, item, &box);
- InsetRect(&box, -5, -5);
- EraseRect(&box);
- InvalThisItemRect(theDialog,theItem);
- }
-
- // turns a static text field into an editable text field
- void ReactivateEdit(DialogPtr theDialog, short theItem){
- short itemType;
- Handle item;
- Rect box;
- GetDialogItem(theDialog, theItem, &itemType, &item, &box);
- itemType = editText;
- SetDialogItem(theDialog, theItem, itemType, item, &box);
- InsetRect(&box, -5, -5);
- EraseRect(&box);
- InvalThisItemRect(theDialog,theItem);
-
- }
-
-
- // manage interface for the dialog, toggling controls and
- // managing which fields can have data entered in them
- void HandleIPopUp(short theItem) {
- ControlHandle popControl;
- popControl = GetCtlHandle(gInvoiceDialog,kIPopUp);
- gInvoiceAction = GetControlValue(popControl);
- switch (gInvoiceAction) {
- case kIFind:
- ReactivateEdit(gInvoiceDialog,kIInvNo);
- InactivateEdit(gInvoiceDialog,kIPartNum1);
- InactivateEdit(gInvoiceDialog,kIPartNum2);
- InactivateEdit(gInvoiceDialog,kIPartQuant1);
- InactivateEdit(gInvoiceDialog,kIPartQuant2);
- InactivateEdit(gInvoiceDialog,kICustName);
- InactivateEdit(gInvoiceDialog,kICustNo);
- SelectDialogItemText(gInvoiceDialog, kIInvNo, 0, 0);
- ToggleControl(gInvoiceDialog,1,1);
- case kINext:
- case kIPrev:
- break;
- case kIInsert:
- ReactivateEdit(gInvoiceDialog,kIPartNum1);
- ReactivateEdit(gInvoiceDialog,kIPartNum2);
- ReactivateEdit(gInvoiceDialog,kIPartQuant1);
- ReactivateEdit(gInvoiceDialog,kIPartQuant2);
- InactivateEdit(gInvoiceDialog,kICustName);
- ReactivateEdit(gInvoiceDialog,kICustNo);
- InactivateEdit(gInvoiceDialog,kIInvNo);
- ToggleControl(gInvoiceDialog,1,2);
- SelectDialogItemText(gInvoiceDialog, kICustNo, 0, 0);
- break;
- case kFindByCust:
- InactivateEdit(gInvoiceDialog,kIPartNum1);
- InactivateEdit(gInvoiceDialog,kIPartNum2);
- InactivateEdit(gInvoiceDialog,kIPartQuant1);
- InactivateEdit(gInvoiceDialog,kIPartQuant2);
- ReactivateEdit(gInvoiceDialog,kICustName);
- InactivateEdit(gInvoiceDialog,kICustNo);
- InactivateEdit(gInvoiceDialog,kIInvNo);
- SelectDialogItemText(gInvoiceDialog, kICustName,0,0);
- ToggleControl(gInvoiceDialog,1,1);
- break;
- }//switch
- }//function
-
- /* when load related is pushed, this function is called. It will
- 1) check to see if customer entry is valid
- 2) check to see if part entry is valid
- 3) load these records into current record structs in memory
- 4) update the dialog
- */
- short LoadRelated(void){
- short LoadErr;
- long theTotal;
- long theTemp;
- long converter;
- // if not in insert mode, go no further and put up alert
- if (gInvoiceAction != kIInsert){
- // load related not working Alert = 133
- short AlertReturn = CautionAlert(133,NULL);
- return -1;
- }// if not in right mode
- // check customer
- LoadErr = CheckCustomer(&CustAddr);
- if ((LoadErr == 0)&&(CustAddr !=-1)) {
- // check part
- LoadErr = CheckPart(&IPartAddr1, &IPartAddr2);
- if ((LoadErr == 0)&&(IPartAddr1 != -1)&&(IPartAddr2 != -1)) {
- // read in customer data
- LoadErr = Read_Data(gInvoiceFCH,sizeof(CustomerType),CustAddr,(Ptr)&iCustomer);
- if (LoadErr != 0) {
- HandleErrorMsg(LoadErr);
- return LoadErr;
- }
- // read in part data 1
- LoadErr = Read_Data(gInvoiceFCH, sizeof(PartType), IPartAddr1, (Ptr)&gPartExtra1);
- if (LoadErr != 0) {
- HandleErrorMsg(LoadErr);
- return LoadErr;
- }
- // read in part data 2
- LoadErr = Read_Data(gInvoiceFCH, sizeof(PartType), IPartAddr2, (Ptr)&gPartExtra2);
- if (LoadErr != 0) {
- HandleErrorMsg(LoadErr);
- return LoadErr;
- }
- //update the dialog
- //if we're here, a valid customer number is in place, as are two part numbers.
- // just need to put in the names to show we really did it.
- SetAString(gInvoiceDialog,kICustName,iCustomer.CustName);
- SetAString(gInvoiceDialog,kIPartName1,gPartExtra1.PartName);
- SetAString(gInvoiceDialog,kIPartName2,gPartExtra2.PartName);
- GetANumber(gInvoiceDialog,kIPartQuant1,&theTemp);
- StringToNum(gPartExtra1.PartPrice,&converter);
- theTemp = converter*theTemp;
- SetANumber(gInvoiceDialog,kIPartPrice1,theTemp);
- GetANumber(gInvoiceDialog,kIPartQuant2,&theTotal);
- StringToNum(gPartExtra2.PartPrice,&converter);
- theTotal = converter*theTotal;
- SetANumber(gInvoiceDialog,kIPartPrice2,theTotal);
- theTotal = theTotal + theTemp;
- SetANumber(gInvoiceDialog,kITotal,theTotal);
- BeginUpdate(gInvoiceDialog);
- DrawDialog(gInvoiceDialog);
- EndUpdate(gInvoiceDialog);
- //toggle the do it button back to working
- ToggleControl(gInvoiceDialog,1,1);
-
- }//Check Part LoadError
- }//CheckCustomer LoadError
- }//function
-
- // utility routines for dialogs
- void SetAString(DialogPtr theDialog, short itemNo, Str255 theString){
- short itemType;
- Handle item;
- Rect box;
- GetDialogItem(theDialog,itemNo,&itemType,&item, &box);
- SetDialogItemText(item,theString);
- SetDialogItem(theDialog,itemNo,itemType,item,&box);
- InvalThisItemRect(theDialog,itemNo);
- }
- void GetAString(DialogPtr theDialog, short itemNo, Str255 theString){
- short itemType;
- Handle item;
- Rect box;
- GetDialogItem(theDialog, itemNo, &itemType, &item, &box);
- GetDialogItemText(item, theString);
- }
-
- void SetANumber(DialogPtr theDialog, short itemNo, long theNumber){
- short itemType;
- Handle item;
- Rect box;
- Str255 theString;
- NumToString(theNumber,theString);
- GetDialogItem(theDialog,itemNo,&itemType,&item, &box);
- SetDialogItemText(item,theString);
- SetDialogItem(theDialog,itemNo,itemType,item,&box);
- InvalThisItemRect(theDialog,itemNo);
- }
-
- void GetANumber(DialogPtr theDialog, short itemNo, long *theNumber) {
- short itemType;
- Handle item;
- Rect box;
- Str255 theString;
- GetDialogItem(theDialog, itemNo, &itemType, &item, &box);
- GetDialogItemText(item, theString);
- StringToNum(theString,theNumber);
- }
-
-
-
-
- // given a valid address of an invoice record, load the invoice, related
- //records, and update the screen.
- short LoadAndFixScreen(FileAddr InvAddr){
- short LAFErr = noErr;
- long searchLong;
- long foundLong;
- long theTemp, theTotal,converter;
-
- FileAddr foundFileAddr;
- //load invoice
- LAFErr = Read_Data(gInvoiceFCH,kInvoiceSize,InvAddr,(Ptr)&gInvoice);
- if (LAFErr != noErr) {
- HandleErrorMsg(LAFErr);
- return LAFErr;
- }
- // find the file address of line items by finding on the sequence num. of item 1
- // these two items are contiguous in the file, so only need to find the first,
- // then read in twice the struct size from the file
- searchLong = gInvoice.LineItem1;
- LAFErr = Find_Equal(kLineItemTree,gInvoiceFCH,(Ptr)&searchLong, (Ptr)&foundLong,&foundFileAddr,kLongCompare);
- if(searchLong != foundLong) {
- LAFErr = -1;
- HandleErrorMsg(LAFErr);
- return LAFErr;
- };
- // read both at once
- LAFErr = Read_Data(gInvoiceFCH, 2*kLineItemSize, foundFileAddr, (Ptr)gLineItems);
- //load the customer info
- searchLong = gInvoice.CustNo;
- // find the address by finding on the customer number
- LAFErr = Find_Equal(kCustomerNumTree, gInvoiceFCH, (Ptr)&searchLong, (Ptr)&foundLong, &foundFileAddr, kLongCompare);
- if(searchLong != foundLong) {
- LAFErr = -1;
- HandleErrorMsg(LAFErr);
- return LAFErr;
- };
- LAFErr = Read_Data(gInvoiceFCH, kCustomerSize, foundFileAddr,(Ptr)&iCustomer);
- //load the parts.
- searchLong = gLineItems[0].PartNo;
- // find the part by finding on part # contained in the line item
- LAFErr = Find_Equal(kPartNumTree,gInvoiceFCH, (Ptr)&searchLong,(Ptr)&foundLong, &foundFileAddr,kLongCompare);
- if(searchLong != foundLong) {
- LAFErr = -1;
- HandleErrorMsg(LAFErr);
- return LAFErr;
- };
- LAFErr = Read_Data(gInvoiceFCH, kPartSize, foundFileAddr,(Ptr)&gPartExtra1);
- // now do the same for the second part
- searchLong = gLineItems[1].PartNo;
- LAFErr = Find_Equal(kPartNumTree,gInvoiceFCH, (Ptr)&searchLong,(Ptr)&foundLong, &foundFileAddr,kLongCompare);
- if(searchLong != foundLong) {
- LAFErr = -1;
- HandleErrorMsg(LAFErr);
- return LAFErr;
- };
- LAFErr = Read_Data(gInvoiceFCH, kPartSize, foundFileAddr,(Ptr)&gPartExtra2);
- //Manage the dialog appearance; just hack stuff
- SetANumber(gInvoiceDialog,kIInvNo,gInvoice.InvoiceNumber);
- SetANumber(gInvoiceDialog,kICustNo,gInvoice.CustNo);
- SetANumber(gInvoiceDialog,kIPartNum1,gLineItems[0].PartNo);
- SetANumber(gInvoiceDialog,kIPartNum2,gLineItems[1].PartNo);
- SetAString(gInvoiceDialog,kICustName,iCustomer.CustName);
- SetAString(gInvoiceDialog,kIPartName1,gPartExtra1.PartName);
- SetAString(gInvoiceDialog,kIPartName2,gPartExtra2.PartName);
- SetANumber(gInvoiceDialog,kIPartQuant1,gLineItems[0].NumItems);
- SetANumber(gInvoiceDialog,kIPartQuant2,gLineItems[1].NumItems);
- StringToNum(gPartExtra1.PartPrice,&converter);
- theTemp = converter*gLineItems[0].NumItems;
- SetANumber(gInvoiceDialog,kIPartPrice1,theTemp);
- StringToNum(gPartExtra2.PartPrice,&converter);
- theTotal = converter*gLineItems[1].NumItems;
- SetANumber(gInvoiceDialog,kIPartPrice2,theTotal);
- theTotal = theTotal + theTemp;
- SetANumber(gInvoiceDialog,kITotal,theTotal);
-
-
- }//function
-
-
- short HandleDoIt(void) {
- // basically a switch statement that handles the different actions
- short doItErr;
- FileAddr LineItemsAddr;
- Str255 TempString;
- long TempLong;
- long searchLong;
- long foundLong;
- FileAddr foundAddr;
- FileAddr prevAddr;
- Str255 foundString;
- switch (gInvoiceAction) {
- case kIInsert:
- //assumes valid part and customer data. This is valid because Load related
- //has already been called
-
- //fill in fields of line items
- // put the part number in the line item fields
- gLineItems[0].PartNo = gPartExtra1.PartNo;
- gLineItems[1].PartNo = gPartExtra2.PartNo;
- // fill in the quantities
- GetANumber(gInvoiceDialog,kIPartQuant1,&TempLong);
- gLineItems[0].NumItems = TempLong;
- GetANumber(gInvoiceDialog,kIPartQuant2,&TempLong);
- gLineItems[1].NumItems = TempLong;
- BlockMove((Ptr)gPartExtra1.PartPrice,(Ptr)gLineItems[0].ItemPrice,6);
- BlockMove((Ptr)gPartExtra2.PartPrice,(Ptr)gLineItems[1].ItemPrice,6);
- //issue a sequence number for the line items
- (Handle)gSequenceHandle = GetResource(kSRType,kSRID);
- HLock((Handle)gSequenceHandle);
- (**gSequenceHandle).LineItems++;
- gLineItems[0].LineItemNo = gInvoice.LineItem1 = (**gSequenceHandle).LineItems;
- (**gSequenceHandle).LineItems++;
- gLineItems[1].LineItemNo = gInvoice.LineItem2 = (**gSequenceHandle).LineItems;
- //all fields of the line items are filled in, and some of the invoice
- //issue a sequence # for the invoice
- (**gSequenceHandle).Invoices++;
- gInvoice.InvoiceNumber = (**gSequenceHandle).Invoices;
- HUnlock((Handle)gSequenceHandle);
- ChangedResource((Handle)gSequenceHandle);
- WriteResource((Handle)gSequenceHandle);
- //fill in the customer # field of the invoice struct
- gInvoice.CustNo = iCustomer.CustNo;
- // now allocate space and start writing data, entering keys.
- doItErr = Get_Bytes(gInvoiceFCH,&LineItemsAddr, 2*kLineItemSize);
- if (doItErr != noErr) {
- HandleErrorMsg(doItErr);
- return doItErr;
- }//real program would do a lot of cleaning up.
- //short cut: enter both line items together
- doItErr = Write_Data(gInvoiceFCH,2*kLineItemSize,LineItemsAddr,(Ptr)gLineItems);
- if (doItErr != noErr) {
- HandleErrorMsg(doItErr);
- return doItErr;
- }//real program would do a lot of cleaning up.
- doItErr = Get_Bytes(gInvoiceFCH,&InvoiceAddr, kInvoiceSize);
- if (doItErr != noErr) {
- HandleErrorMsg(doItErr);
- return doItErr;
- }//real program would do a lot of cleaning up.
- doItErr = Write_Data(gInvoiceFCH,kInvoiceSize, InvoiceAddr, (Ptr)&gInvoice);
- //data is entered. Now enter keys. always enter data first.
- //better to have orphan record than key pointing to nowhere.
- //enter key to the invoice by num.
- doItErr = Insert_Key(kInvoiceTree,kUniqueKeys,gInvoiceFCH,(Ptr)&gInvoice.InvoiceNumber,InvoiceAddr,kLongCompare);
- // this is one of the most critical lines of code in the program.
- //uses customer name as key, point to "record address" of Invoice Number
- doItErr = Insert_Key(kInvoiceCustTree,kDuplicateKeys,gInvoiceFCH, (Ptr)&iCustomer.CustName,gInvoice.InvoiceNumber,kPStringCompare);
- //insert the two line item keys.
- doItErr = Insert_Key(kLineItemTree,kUniqueKeys,gInvoiceFCH,(Ptr)&gLineItems[0].LineItemNo,LineItemsAddr,kLongCompare);
- doItErr = Insert_Key(kLineItemTree,kUniqueKeys, gInvoiceFCH,(Ptr)&gLineItems[1].LineItemNo,LineItemsAddr+4,kLongCompare);
- SetANumber(gInvoiceDialog,kIInvNo,gInvoice.InvoiceNumber);
- ToggleControl(gInvoiceDialog,1,2);
- // need this stuff for proper actions of next/previous calls
- currentInvAddr = InvoiceAddr;
- BlockMove((Ptr)&iCustomer.CustName,(Ptr)currentInvCustName,256);
- currentInvNumber = gInvoice.InvoiceNumber;
- currentInvCustNumber = iCustomer.CustNo;
- //phew!
- break;
- case kIFind :
- /* simple find. Find the invoice by looking up the main invoice
- address (the sequence number) in the appropriate tree*/
- GetANumber(gInvoiceDialog,kIInvNo,&searchLong);
- doItErr = Find_Equal(kInvoiceTree, gInvoiceFCH,(Ptr)&searchLong,(Ptr)&foundLong, &foundAddr, kLongCompare);
- findingBy = kFindByNumber;
- if ((doItErr == noErr)&&(foundAddr!=-1)){
- doItErr = LoadAndFixScreen(foundAddr);
- InvoiceAddr = foundAddr;
- currentInvAddr = foundAddr;
- currentInvNumber = gInvoice.InvoiceNumber;
- }
- break;
- case kINext :
- // see comments under kIFind, kFindByCust
- if (findingBy ==kFindByNumber){
- prevAddr = currentInvAddr;
- searchLong = currentInvNumber;
- doItErr = Find_Next(kInvoiceTree,gInvoiceFCH,(Ptr)&searchLong,prevAddr,(Ptr)&foundLong,&foundAddr, kLongCompare);
- }
- else {
- prevAddr = currentInvCustNumber;
- BlockMove((Ptr)currentInvCustName,(Ptr)TempString,256);
- doItErr = Find_Next(kInvoiceCustTree, gInvoiceFCH,(Ptr)TempString,prevAddr,(Ptr)foundString,&foundAddr,kPStringCompare);
- searchLong = foundAddr;
- currentInvCustNumber = searchLong;
- doItErr = Find_Equal(kInvoiceTree, gInvoiceFCH,(Ptr)&searchLong,(Ptr)&foundLong, &foundAddr, kLongCompare);
- InvoiceAddr = foundAddr;
-
- }
- if ((doItErr == noErr)&&(foundAddr!=-1)){
- doItErr = LoadAndFixScreen(foundAddr);
- InvoiceAddr = foundAddr;
- currentInvAddr = foundAddr;
- if (findingBy == kFindByNumber)
- currentInvNumber = foundLong;
- else {
- BlockMove((Ptr)foundString,(Ptr)currentInvCustName,256);
- }
- }
- break;
- case kIPrev :
- // see comments under kIFind, kFindByCust
- if (findingBy ==kFindByNumber){
- prevAddr = currentInvAddr;
- searchLong = currentInvNumber;
- doItErr = Find_Previous(kInvoiceTree,gInvoiceFCH,(Ptr)&searchLong,prevAddr,(Ptr)&foundLong,&foundAddr, kLongCompare);
- }
- else {
- prevAddr = currentInvCustNumber;
- BlockMove((Ptr)currentInvCustName,(Ptr)TempString,256);
- doItErr = Find_Previous(kInvoiceCustTree, gInvoiceFCH,(Ptr)TempString,prevAddr,(Ptr)foundString,&foundAddr,kPStringCompare);
- searchLong = foundAddr;
- currentInvCustNumber = searchLong;
- doItErr = Find_Equal(kInvoiceTree, gInvoiceFCH,(Ptr)&searchLong,(Ptr)&foundLong, &foundAddr, kLongCompare);
- }
- if ((doItErr == noErr)&&(foundAddr!=-1)){
- doItErr = LoadAndFixScreen(foundAddr);
- InvoiceAddr = foundAddr;
- currentInvAddr = foundAddr;
- if (findingBy == kFindByNumber)
- currentInvNumber = foundLong;
- else
- BlockMove((Ptr)foundString,(Ptr)currentInvCustName,256);
- }
-
- break;
- case kFindByCust :
- // Get the name of the customer for the search
- GetAString(gInvoiceDialog,kICustName,TempString);
- prevAddr = 0;
- // look for the customer in the kInvoiceCustTree. The returned four
- // byte "address" is actually the sequence number of the invoice
- doItErr = Find_Next(kInvoiceCustTree, gInvoiceFCH,(Ptr)TempString,prevAddr,(Ptr)&foundString, &foundAddr, kPStringCompare);
- searchLong = foundAddr;
- currentInvCustNumber = searchLong;
- // now find the true address of the invoice by searching the invoice
- // sequence number tree with the foundAddr from the above call as the key
- doItErr = Find_Equal(kInvoiceTree, gInvoiceFCH,(Ptr)&searchLong,(Ptr)&foundLong, &foundAddr, kLongCompare);
- findingBy = kFindByName;
- if ((doItErr == noErr)&&(foundAddr!=-1)){
- doItErr = LoadAndFixScreen(foundAddr);
- InvoiceAddr = foundAddr;
- currentInvAddr = foundAddr;
- BlockMove((Ptr)foundString,(Ptr)currentInvCustName,256);
- }
- break;
-
- default:
- break;
- }//switch
- }//function
-
- void HandleInvoiceAction(EventRecord *theEvent,short *theItem){
-
- switch (*theItem) {
- case kIPopUp:
- HandleIPopUp(*theItem);
- break;
- case kLoadRelated:
- actionErr = LoadRelated();
- break;
- case kIDoIt:
- actionErr = HandleDoIt();
- break;
- }//switch
- // irrespective of the action, update the dialog when done
- BeginUpdate(gInvoiceDialog);
- DrawDialog(gInvoiceDialog);
- EndUpdate(gInvoiceDialog);
-
- return;
- }